home *** CD-ROM | disk | FTP | other *** search
/ Adobe Graphics & Publishing SDK 1996 December / Adobe Graphics & Publishing SDK 1996 December.iso / pc / ps40sdk / examples / common / headers.h / dialogutilities.h next >
Encoding:
C/C++ Source or Header  |  1996-09-29  |  7.0 KB  |  260 lines

  1. /* Plug-in module utility routines */
  2.  
  3. /* Copyright 1993-6 by Adobe Systems, Inc.  All rights reserved. */
  4.  
  5. /* The routines in this module provide a collection of utilities for doing
  6.  * things like centering dialogs, etc.. They expect that the host's A5-world
  7.  * is the currently active A5-world.
  8.  */
  9.  
  10. #ifndef __DialogUtilities_H__
  11. #define __DialogUtilities_H__
  12.  
  13. #include <Dialogs.h>
  14. #include <stddef.h>
  15. #include <Types.h>
  16. #include <Gestalt.h>
  17. #include <string.h>
  18.  
  19. #include "PITypes.h"
  20. #include "PIGeneral.h"
  21. #include "PIUtilities.h"
  22.  
  23. /*****************************************************************************/
  24.  
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28.  
  29. /*****************************************************************************/
  30.  
  31. /* Define constants. */
  32. #define AlertID            16990
  33. #define kBadNumberID    AlertID
  34. #define kBadDoubleID    kBadNumberID+1
  35. #define kNeedVers        kBadDoubleID+1
  36. #define kWrongHost        kNeedVers+1
  37. #define StringResource    'STR '
  38.  
  39. /* Errors */
  40. enum
  41. {
  42.     /* noErr = 0 */
  43.     errOutOfRange = 1,
  44.     errNotANumber
  45. };
  46.  
  47. /*****************************************************************************/
  48.  
  49. /* Set the cursor to the arrow cursor. */
  50.  
  51. void SetArrowCursor ();
  52.  
  53. /*****************************************************************************/
  54.  
  55. /* Centers a dialog template 1/3 of the way down on the main screen. */
  56.  
  57. void CenterDialog (DialogTHndl dt);
  58.  
  59. /* The following routine sets up a moveable modal dialog. */
  60.  
  61. void SetUpMoveableModal (DialogTHndl dt, OSType hostSig);
  62.                          
  63. /* The following routine takes the place of ModalDialog in running moveable
  64.  * modal dialogs.
  65.  */
  66.                          
  67. void MoveableModalDialog (DialogPtr dp,
  68.                           ProcessEventProc processEvent,
  69.                           ModalFilterProcPtr filter,
  70.                           short *item);
  71.                           
  72. /* Except within the filter procedure for such moveable modal dialogs, we need
  73.    to call the following routine to get the window refcon since
  74.    MoveableModalDialog stomps it. */
  75.    
  76. long GetMoveableWRefCon (DialogPtr dp);
  77.                           
  78. /* The following routine displays a centered alert. */
  79.  
  80. short ShowAlert (short alertID);
  81.  
  82. /* Displays a cross-platform alert with a version number. */
  83.  
  84. short ShowVersionAlert (Handle hDllInstance,
  85.                         short alertID, 
  86.                         short stringID,
  87.                         Str255 versText1,
  88.                         Str255 versText2);
  89.  
  90. /* The following routine displays a centered caution alert from a string. */
  91.  
  92. short ShowAlertType (Handle hDllInstance,
  93.                      short alertID, 
  94.                      short stringID, 
  95.                      Str255 minText, 
  96.                      Str255 maxText,
  97.                      short alertType);
  98.  
  99. enum
  100. { // constants defined for alert routine
  101.     PIAlertCaution,
  102.     PIAlertStop
  103. };
  104.  
  105. #define ShowCaution(h, alertID, stringID, min, max)    \
  106.     ShowAlertType(h, alertID, stringID, min, max, PIAlertCaution)
  107.     
  108. #define ShowStop(h, alertID, stringID, min, max)    \
  109.     ShowAlertType(h, alertID, stringID, min, max, PIAlertStop)
  110.  
  111. /* The following routine displays a standard about box dialog. */
  112.  
  113. void ShowAbout (OSType hostSign, short dialogID);
  114.  
  115. /*****************************************************************************/
  116. /* Set an item hook so that it will outline the OK button in a dialog. */
  117.  
  118. void SetOutlineOKHook (DialogPtr dp, short hookItem);
  119.  
  120. /* The following routine sets a user item to be a group box.  It expects
  121.    the next item to be the title for the group box. */
  122.  
  123. void SetOutlineGroup (DialogPtr dp, short groupItem);
  124.  
  125. /*****************************************************************************/
  126.  
  127. /* The following routine selects an edit text item. */
  128.  
  129. void SelectTextItem (DialogPtr dp, short item);
  130.  
  131. /* The following routine sets the text of a text item. */
  132.  
  133. void StuffText (DialogPtr dp, short item, Str255 text);
  134.  
  135. /* The following routine extracts the text of a text item. */
  136.  
  137. void FetchText (DialogPtr dp, short item, Str255 text);
  138.  
  139.                      
  140. /* The following routine stuffs a numeric value into a text field. */
  141.  
  142. void StuffNumber (DialogPtr dp, short item, long value);
  143.  
  144. /* Here is the corresponding routine to retrieve the value from a text
  145.    field.  It will do range checking and validate that it has been
  146.    handed a number.
  147.   
  148.    It returns noErr (0) if it gets a valid value in the field. */
  149.  
  150. short FetchNumber (DialogPtr dp,
  151.                        short item,
  152.                       long min,
  153.                       long max,
  154.                       long *value);
  155.  
  156. /* This is the corresponding alert routine when the range is not valid. */
  157.  
  158. void AlertNumber (DialogPtr dp,
  159.                   short item,
  160.                   long min,
  161.                   long max,
  162.                   long *value,
  163.                   Handle hDllInstance,
  164.                   short alertID,
  165.                   short numberErr);
  166.                                    
  167. /* Stuffs a double/float value into a text field. */
  168.  
  169. void StuffDouble (DialogPtr dp, short item, double value, short precision);
  170.  
  171. /* Grabs a double/float from a dialog. */
  172.  
  173. short FetchDouble (DialogPtr dp,
  174.                      short item,
  175.                      double min,
  176.                      double max,
  177.                      double *value);
  178.                      
  179. void AlertDouble (DialogPtr dp,
  180.                      short item,
  181.                      double min,
  182.                      double max,
  183.                      double *value,
  184.                      Handle hDllInstance,
  185.                      short alertID,
  186.                      short numberErr);
  187.                      
  188. /*****************************************************************************/
  189.  
  190. /* Set the state of a check box (or radio button). */
  191.  
  192. void SetCheckBoxState (DialogPtr dp, short item, Boolean checkIt);
  193.  
  194. /* Determine the state of a check box (or radio button). */
  195.  
  196. Boolean GetCheckBoxState (DialogPtr dp, short item);
  197.  
  198. /* Toggle a check box and return the new state. */
  199.  
  200. Boolean ToggleCheckBoxState (DialogPtr dp, short item);
  201.  
  202. /* Set a radio group (from first to last item) to reflect the selection. */
  203.  
  204. void SetRadioGroupState (DialogPtr dp, short first, short last, short item);
  205.                          
  206. /* Get the selected button within a radio group. */
  207.  
  208. short GetRadioGroupState (DialogPtr dp, short first, short last);
  209.  
  210. /* Set the value for a pop-up menu. */
  211.  
  212. void SetPopUpMenuValue (DialogPtr dp, short item, short newValue);
  213.  
  214. /* Get the value for a pop-up menu. */
  215.  
  216. short GetPopUpMenuValue (DialogPtr dp, short item);
  217.  
  218. /* Utility routine to show or hide an item. */
  219.  
  220. void ShowHideItem (DialogPtr dp, short item, Boolean state);
  221.  
  222. /* Utility routine to disable a control. */
  223.  
  224. void DisableControl (DialogPtr dp, short item);
  225.  
  226. /* Utility routine to enable a control. */
  227.  
  228. void EnableControl (DialogPtr dp, short item);
  229.  
  230. /* Utility routine to enable (TRUE) or disable (FALSE) a control. */
  231.  
  232. void EnableDisableControl (DialogPtr dp, short item, Boolean state);
  233.  
  234. /* Utility routine to invalidate an item. */
  235.  
  236. void InvalItem (DialogPtr dp, short item);
  237.  
  238. /*****************************************************************************/
  239.  
  240. /* Little routine to flash a button set off by a keystroke. */
  241.  
  242. void FlashDialogButton (DialogPtr dp, short item);
  243.  
  244. /* Perform standard handling for check boxes and radio buttons. For radio
  245.    buttons, we assume that the group for the radio button extends forward
  246.    and backward in the DITL as long as the item type is radio button. */
  247.    
  248. void PerformStandardDialogItemHandling (DialogPtr dp, short item);
  249.  
  250. /*****************************************************************************/
  251.  
  252. QDGlobals *GetQDGlobals (void);
  253.  
  254. #ifdef __cplusplus
  255. } /* End of extern "C" block. */
  256. #endif
  257.  
  258. /*****************************************************************************/
  259.  
  260. #endif /* __DialogUtilities__ */